package geoway.bmf.keycloak.controller;

import geoway.bmf.keycloak.constant.ConstantData;
import geoway.bmf.keycloak.utils.KeycloakContext;
import org.keycloak.representations.AccessToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Optional;

/**
 * @author yrt
 * @description
 * @date 2022/11/11 11:42
 */

@RestController
@RequestMapping(path=ConstantData.BasicApi)
public class KeyCloakController {

    @Autowired
    private HttpServletRequest httpServletRequest;

    @GetMapping(value = "getValue")
    public String getValue(){
        Optional<AccessToken> accessToken = KeycloakContext.getAccessToken();
        return "Hello keycloak!";
    }

}
